/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package action.organization;

import com.opensymphony.xwork2.ActionSupport;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
import po.Organization;
import service.OrgService;
import myUtils.Constants;

/**
 *
 * @author luyang
 */
public class UpdateOrgAction extends ActionSupport implements ServletRequestAware
{
    private HttpServletRequest request;
    private OrgService orgService;
    private Organization organization;

    @Override
    public String execute()
    {
        //organization=new Organization();
         int id =request.getParameter("id")==null?3:Integer.parseInt((String) request.getParameter("id"));
        organization = orgService.getOrg(id);
       
        organization.setType(request.getParameter("type")==null?Constants.CHECKED_ORG:Integer.parseInt((String) request.getParameter("type")));
        orgService.updateOrg(organization);
        request.setAttribute("msg", "Success updated!");
        System.out.println(request.getAttribute("msg"));

        return SUCCESS;
    }

    public void setOrganization(Organization organization)
    {
        this.organization=organization;
    }

    public void setOrgService(OrgService orgService)
    {
        this.orgService=orgService;
    }

    public void setServletRequest(HttpServletRequest request)
    {
        this.request=request;
    }

}
